/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  dev
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    format      ascii;
    class       dictionary;
    location    "system";
    object      snappyHexMeshDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#includeEtc "caseDicts/mesh/generation/snappyHexMeshDict.cfg"

castellatedMesh on;
snap            on;
addLayers       on;

geometry
{
    body
    {
        type triSurface;
        file "body.obj";
    }

    frontWheels
    {
        type triSurface;
        file "frontWheels.obj";
    }

    rearWheels
    {
        type triSurface;
        file "rearWheels.obj";
    }

    upstream
    {
        type box;
        min (-10 -1.5  0);
        max ( 3   1.5  0.8);
    }

    underbody
    {
        type box;
        min (-10 -1.5  0);
        max ( 3   1.5  0.15);
    }

    wake
    {
        type box;
        min ( 3 -1.2  0);
        max ( 6  1.2 1.4);
    }

    downstream
    {
        type box;
        min ( 3 -1.5  0);
        max (30  1.5 1.8);
    }
};

castellatedMeshControls
{
    features ();

    refinementSurfaces
    {
        body
        {
            level (5 5);
            patchInfo { type wall; }
        }

        ".*Wheels" // level 5 needed to avoid single cells in treads
        {
            level (4 5);
            patchInfo { type wall; }
        }
    }

    refinementRegions
    {
        body
        {
            mode    distance;
            levels  ((0.2 5));
        }

        "(wake|underbody)"
        {
            mode    inside;
            level   4;
        }

        ".*stream"
        {
            mode    inside;
            level   3;
        }
    }

    insidePoint (0 0 3);
    nCellsBetweenLevels 5;
}

snapControls {}

addLayersControls
{
    layers
    {
        body
        {
            nSurfaceLayers 2;
        }
    }

    relativeSizes       on;
    expansionRatio      1.2;
    finalLayerThickness 0.5;
    minThickness        1e-3;
    maxThicknessToMedialRatio 0.6;
}

writeFlags ();

mergeTolerance 1e-6;

// ************************************************************************* //
